package com.example.sportmeetserver.service;

import com.example.sportmeetserver.dao.UserDao;
import com.example.sportmeetserver.entity.User;
import com.example.sportmeetserver.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    private final UserDao userDao;

    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    public User findByAccountAndPassword(UserVo userVo) {
        // 根据实际业务逻辑判断用户名和密码是否匹配
        User user = userDao.findByAccount(userVo.getAccount());

        if (!user.getPassword().equals(userVo.getPassword())) {
            return null;
        }

        return user;
    }

    public boolean validateUserType(UserVo userVo) {
        User user = userDao.findByAccount(userVo.getAccount());

        if (user == null) {
            return false;
        }

        return user.getUserType().equals(userVo.getUserType());
    }

}
